home *** CD-ROM | disk | FTP | other *** search
/ SGI Performance Co-Pilot 1.3 / SGI Performance Co-Pilot 1.3.iso / dist / dist6.4 / pcp.idb / usr / sbin / dkvis.z / dkvis
Text File  |  1997-04-03  |  6KB  |  261 lines

  1. #!/bin/sh
  2. #  Copyright (c) 1994 Silicon Graphics, Inc.
  3. #  ALL RIGHTS RESERVED.
  4. #  U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND
  5. #  Use, duplication or disclosure by the Government is subject to
  6. #  restrictions as set forth in FAR 52.227.19(c)(2) or subparagraph
  7. #  (c)(1)(ii) of the Rights in Technical Data and Computer Software clause
  8. #  at DFARS 252.227-7013 and/or similar or successor clauses in the FAR,
  9. #  or the DOD or NASA FAR Supplement.  Contractor/manufacturer is Silicon
  10. #  Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
  11. #  THIS SOFTWARE CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION OF
  12. #  SILICON GRAPHICS, INC.  ANY DUPLICATION, MODIFICATION, DISTRIBUTION, OR
  13. #  DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN
  14. #  PERMISSION OF SILICON GRAPHICS, INC.
  15. # /
  16.  
  17. #
  18. # $Id: dkvis.sh,v 2.12 1997/03/21 08:24:03 kenmcd Exp $
  19. #
  20.  
  21. tmp=/tmp/$$
  22. trap "rm -f $tmp.*; exit" 0 1 2 3  15
  23. rm -f $tmp.*
  24.  
  25. . /usr/pcp/lib/pmview-args
  26.  
  27. _usage()
  28. {
  29.     echo >$tmp.msg 'Usage: '$prog' [options]
  30.  
  31. options:
  32.   -m   maxrate    maximum I/O rate expected (integer) [default 100]
  33.   -r              display Read I/O rate
  34.   -v   version    generate scene for different versions of pmview [default 2]
  35.   -V              verbose/diagnostic output
  36.   -w              display Write I/O rate
  37.  
  38. pmview(1) options:'
  39.  
  40.     _pmview_usage >>$tmp.msg
  41.     echo >>$tmp.msg
  42.     echo 'Default title is: Total I/O Rate for Host' >>$tmp.msg
  43.     _pmview_info -f $tmp.msg
  44. }
  45.  
  46. verbose=false
  47. version="2"
  48. type=total
  49. Type=Total
  50. max=150
  51.  
  52. _pmview_args "$@"
  53.  
  54. if [ -n "$otherArgs" ]
  55. then
  56.     while getopts "?m:rv:Vw" c $otherArgs
  57.     do
  58.     case $c
  59.     in
  60.         m)
  61.         max=$OPTARG
  62.         # and now the obscure +ve integer checking bit
  63.         # ...note the creative use of unary - to prevent leading signs
  64.         if [ "X-$max" != "X`expr 0 + -$max 2>/dev/null`" ]
  65.         then
  66.             _pmview_error "-m option must have a positive integral argument"
  67.             # NOTREACHED
  68.         fi
  69.         ;;
  70.         r)
  71.         if [ $type != total ]
  72.         then
  73.             _pmview_error "only one -r or -w option may be specified"
  74.             # NOTREACHED
  75.         fi
  76.         type=read
  77.         Type=Read
  78.         ;;
  79.         v)
  80.         version=$OPTARG
  81.         if [ $version != "1" -a $version != "2" ]
  82.         then
  83.             _pmview_error "only versions 1 and 2 supported for -v"
  84.             # NOTREACHED
  85.         fi
  86.         ;;
  87.         V)
  88.         verbose=true
  89.         ;;
  90.         w)
  91.         if [ $type != total ]
  92.         then
  93.             _pmview_error "only one -r or -w option may be specified"
  94.             # NOTREACHED
  95.         fi
  96.         type=write
  97.         Type=Write
  98.         ;;
  99.         ?)
  100.         _usage
  101.         exit 1
  102.         ;;
  103.  
  104.     esac
  105.     done
  106.     set -- $otherArgs
  107.     shift `expr $OPTIND - 1`
  108.     if [ $# -gt 0 ]
  109.     then
  110.     _usage
  111.     exit 1
  112.     fi
  113. fi
  114.  
  115. if [ "X$arch" != X ]
  116. then
  117.     pmprobe $namespace -a $arch -I irix.disk.dev.$type >$tmp.dk
  118.     host=`pmdumplog -l $arch | awk '/^Performance/ {print $5}' | sed -e 's/,//g'`
  119.     [ "X$host" = X ] && host="unknown host"
  120.     host="$host (Archive $arch)"
  121. elif [ "X$host" = X ]
  122. then
  123.     host=`/usr/bsd/hostname`
  124. fi
  125.  
  126. # if not an archive, contact the host
  127. [ ! -f $tmp.dk ] && pmprobe $namespace -h $host -I irix.disk.dev.$type >$tmp.dk
  128.  
  129. eval `sed <$tmp.dk \
  130.     -e 's/"//g' \
  131.     -e 's/$/ /' \
  132.     -e "s/^[^ ]* /ndisk=/" \
  133.     -e 's/ / disks="/' \
  134.     -e 's/"$/""/' \
  135.     -e 's/ $/"/'`
  136.  
  137. if [ -z "$disks" -o -z "$ndisk" -o "$ndisk" -lt 1 ]
  138. then
  139.     echo "Cannot get disk inventory!" >$tmp.msg
  140.     cat $tmp.dk >>$tmp.msg
  141.     _pmview_error -f $tmp.msg
  142.     # NOTREACHED
  143. fi
  144.  
  145. rm -f $tmp.conf
  146. touch $tmp.conf
  147.  
  148. if [ "$version" = 1 ]
  149. then
  150.     vstring="# pmview 1.0"
  151. else
  152.     vstring="pmview Version $version.0"
  153. fi
  154.  
  155. cat << end-of-file >> $tmp.conf
  156. $vstring
  157. #
  158. # dkvis
  159. #
  160. end-of-file
  161.  
  162. if $verbose
  163. then
  164.     echo "# Disk Inventory:" >> $tmp.conf
  165.     echo $disks | fmt | sed -e 's/^/#    /' >> $tmp.conf
  166. fi
  167.  
  168. if [ "$version" = "2" ]
  169. then
  170.  
  171. #
  172. # pmview 2.0
  173. #
  174.  
  175.     echo '
  176. _scale 1.1
  177. _colorlist colors ( green1 blue1 red1 cyan1 purple1 yellow1 )
  178. _labeledbar (
  179.     _colorlist colors
  180.     _metrics (' >> $tmp.conf
  181.  
  182.    echo "$disks" \
  183. | tr ' ' '\012' \
  184. | sed \
  185.     -e 's/.../& /' \
  186.     -e 's/\([0-9]\)d\([0-9]\)/\1 d \2/' \
  187.     -e 's/\([0-9]\)l\([0-9]\)/\1 l \2/' \
  188. | sort +0 -1 +1n -2 +3n -4 \
  189. | awk '
  190. BEGIN    { type = ""; ctl = ""; list = ""; labels = ""}
  191.     { if ($1 != type || $2 != ctl) {
  192.         if (list != "")
  193.             print "        irix.disk.dev.'$type'[" list "] " '$max'
  194.         list = $1 $2 $3 $4 $5 $6
  195.         labels = labels " \"" $1 $2 "\""
  196.         type = $1
  197.         ctl = $2
  198.       }
  199.       else
  200.         list = list "," $1 $2 $3 $4 $5 $6
  201.     }
  202. END    { if (list != "")
  203.         print "        irix.disk.dev.'$type'[" list "] " '$max'
  204.         print "    )"
  205.         print "    _metriclabels (" labels " )"
  206.         print ")"
  207.     }' >> $tmp.conf
  208.  
  209. else
  210.  
  211. #
  212. # pmview 1.0
  213. #
  214.  
  215.     echo "$disks" \
  216. | tr ' ' '\012' \
  217. | sed \
  218.     -e 's/.../& /' \
  219.     -e 's/\([0-9]\)d\([0-9]\)/\1 d \2/' \
  220.     -e 's/\([0-9]\)l\([0-9]\)/\1 l \2/' \
  221. | sort +0 -1 +1n -2 +3n -4 \
  222. | awk '
  223. BEGIN    { type = ""; ctl = ""; x = 0
  224.       col[0] = "0.0 1.0 0.0"
  225.       col[1] = "0.0 0.0 1.0"
  226.       col[2] = "1.0 0.0 0.0"
  227.       col[3] = "0.0 1.0 1.0"
  228.       col[4] = "1.0 1.0 0.0"
  229.       col[5] = "1.0 0.0 1.0"
  230.       col[6] = "0.0 1.0 0.5"
  231.       col[7] = "0.5 0.0 1.0"
  232.       col[8] = "1.0 0.5 0.0"
  233.       col[9] = "0.5 1.0 0.5"
  234.       col[10] = "1.0 0.5 0.5"
  235.       col[11] = "0.5 0.5 1.0"
  236.     }
  237.     { if ($1 != type || $2 != ctl) {
  238.         type = $1; ctl = $2; x++; y = 0; tag = $1 $2
  239.       }
  240.       else
  241.         tag = "-"
  242.       print x " " y " " col[y % 12] " '$max' " tag " irix.disk.dev.'$type' " $1 $2 $3 $4 $5 $6
  243.       y++
  244.     }' >> $tmp.conf
  245.  
  246. fi
  247.  
  248. $verbose && cat $tmp.conf
  249.  
  250. if [ -z "$titleArg" ]
  251. then
  252.     titleArg="$Type Disk I/O Rate for Host $host"
  253. fi
  254.  
  255. eval pmview <$tmp.conf $args -title "'$titleArg'" -xrm "'*iconName: dkvis'"
  256.  
  257. exit
  258.